package com.njym.java.security.admin.rest;

import com.github.pagehelper.PageInfo;
import com.njym.java.security.admin.biz.AnAmbassadorBiz;
import com.njym.java.security.admin.entity.AnAmbassador;
import com.njym.java.security.common.rest.BaseController;
import com.njym.java.security.common.util.ResponseUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import tk.mybatis.mapper.entity.Example;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("anAmbassador")
public class AnAmbassadorController extends BaseController<AnAmbassadorBiz, AnAmbassador> {

    /**
     * 排序
     * @return
     */
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    @ResponseBody
    public Object lists(){
        Example example = new Example(AnAmbassador.class);
        example.orderBy("attr1");
        List<AnAmbassador> list = baseBiz.selectByExample(example);
        long total = PageInfo.of(list).getTotal();
        Map<String, Object> data = new HashMap<>(2);
        data.put("list", list);
        data.put("total", total);
        return ResponseUtil.ok(data);

    }

}